package com.jjwxc.jwjskandriod.adapter;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.jjwxc.jwjskandriod.fragment.BookshelfFragment;
import com.jjwxc.jwjskandriod.fragment.MainSuggestFragment;
import com.jjwxc.jwjskandriod.fragment.MyFragment;
import com.jjwxc.jwjskandriod.fragment.StackFragment;
import com.jjwxc.jwjskandriod.fragment.SuggestFragment;

public class MainFragmentAdapter extends FragmentPagerAdapter {
    FragmentManager mFragmentManager;
    public MainFragmentAdapter(FragmentManager fm) {
        super(fm);
        mFragmentManager = fm;
    }

    @Override
    public Fragment getItem(int i) {
        Fragment fragment = null;
        switch (i) {
            case 0:
                fragment = new BookshelfFragment();
                break;
            case 1:
                fragment = new MainSuggestFragment();
                break;
            case 2:
                fragment = new StackFragment();
                break;
            case 3:
                fragment = new MyFragment();
                break;
            default:
                break;
        }
        return fragment;
    }

    @Override
    public int getCount() {
        return 4;
    }
    public FragmentManager getFragmentManager() {
        return mFragmentManager;

    }
}

